'use strict';

/**
 * @ngdoc directive
 * @name izzyposWebApp.directive:adminPosHeader
 * @description
 * # adminPosHeader
 */
angular.module('sbAdminApp')
	.directive('headerNotification', function() {
		return {
			templateUrl: 'scripts/directives/header/header-notification/header-notification.html',
			restrict: 'E',
			replace: true,
			controller: function($scope, $rootScope, $cookieStore, $state) {
				$scope.teacher = $cookieStore.get('teacher');

				$scope.$watch(function() {
					return $cookieStore.get('teacher');
				}, function() {
					$scope.teacher = $cookieStore.get('teacher');
				}, true);

				$scope.logout = function() {
					$rootScope.teacher = undefined;
					$cookieStore.remove('teacher');
					$cookieStore.remove('authToken');
					$state.go('login');
				};
			}
		}
	});